<?php

namespace HospitalApi\Controller;
use Think\Controller;
//use Common\RestController;
use Common\Model\HospitalLoginLogic;

class LoginController extends Controller {

	/**
	 * 登陆
	 * phone , password
	 */
	public function login(){
		file_put_contents(RUNTIME_PATH.'ok.log', time().json_encode($_POST).PHP_EOL,FILE_APPEND);
		$HospitalLoginModel = new HospitalLoginLogic;
		$res = $HospitalLoginModel->login(I('phone'),I('password'));
		if($res!==true){
			$this->ajaxReturn(['status'=>0,'error_info'=>$res]);
		}

		//获取登陆成功后的用户token
		$token = $HospitalLoginModel->getLoginToken();
		$userId = $HospitalLoginModel->getUserId();
		$this->ajaxReturn(['status'=>1,'data'=>['token'=>$token,'user_id'=>$userId]]);
	}

    
}